/**
 * @author Jerome Monceaux
 * @version 1.0
 * 
 * used to send gui event to modules
 **/
package org.hh.common;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.MotionEvent;

/**
 * 
 * @author Jerome Monceaux
 *
 * This class is used to notify all modules on display events.
 */
public class GUIDispatcher extends HHObject {

	private Object[] fOnDrawParam = null;
	private Object[] fOnTouchParam = null;
	public GUIDispatcher(String fName) {
		super(fName);
	}

	public void initView(Context context){
		setChanged();
		notifyObservers(new Object[]{"onInitView", new Object[]{context}});
	}
	
	public void onTouch(MotionEvent event){
		setChanged();
		if( fOnTouchParam == null)
			fOnTouchParam = new Object[]{"onTouch", new Object[]{event}};
		notifyObservers(fOnTouchParam);
	}

	public void onDraw(Canvas canvas, Paint paint){
		setChanged();
		if( fOnDrawParam == null)
			fOnDrawParam = new Object[]{"onDraw", new Object[]{canvas, paint}};
		notifyObservers(fOnDrawParam);
	}

	public void finish() {
		setChanged();
		notifyObservers(new Object[]{"finish", null});
	}
}
